/*
* 包含多个对应事件回调函数的对象
* */

import storage from "../utils/storage";
import {ADD, ALLSELECT, READTODOS, REMOVE, REMOVEALLTODOS} from "./mutations-type";

export default {
  //触发mutation：添加todo
  addToDo({commit}, todo){
    commit(ADD, todo)
  },

  //触发actions：删除todo
  delToDo({commit}, index){
    commit(REMOVE, index)
  },

  //触发actions：选择的所有的todo
  selectAllTodos({commit}, isSelect){
    commit(ALLSELECT, isSelect)
  },

  //触发actions：清除选中的todo
  clearSelectTodos({commit}){
    commit(REMOVEALLTODOS);
  }


  //触发actions：异步缓存数据
  // asyncReadTodos({commit}){
  //   setTimeout(function () {
  //     let todos = storage.getTodos();
  //     commit(READTODOS, todos);
  //   }, 1000)
  // }


}
